export const getAccessToken = () => {
    return localStorage.getItem('accessToken') || '';
};

export const setAccessToken = (token = '') => {
    return localStorage.setItem('accessToken', token);
};

export const getRefreshToken = () => {
    return localStorage.getItem('refreshToken') || '';
};

export const setRefreshToken = (token = '') => {
    return localStorage.setItem('refreshToken', token);
};

export const getUserName = () => {
    return localStorage.getItem('userName') || '';
};

export const setUserName = (token = '') => {
    return localStorage.setItem('userName', token);
};

// export const getUserId = () => {
//     return localStorage.getItem('userId') || '';
// };
// export const setUserId = (userId = '') => {
//     return localStorage.setItem('userId', userId);
// };

// export const getUserInfo = () => {
//     return JSON.parse(localStorage.getItem('userInfo')) || {};
// };
// export const setUserInfo = (userInfo = {}) => {
//     return localStorage.setItem('userInfo', JSON.stringify(userInfo));
// };

export const getUserAuthInfo = () => ({
    accessToken: getAccessToken(),
    refreshToken: getRefreshToken(),
    getUserName: getUserName(),
    // userId: getUserId(),
    // userInfo: getUserInfo(),
});

export const setUserAuthInfo = ({ accessToken, refreshToken, userId, userInfo, userName }) => {
    if (accessToken !== undefined) setAccessToken(accessToken);
    if (refreshToken !== undefined) setRefreshToken(refreshToken);
    if (userName !== undefined) setUserName(userName);
    // if (userId !== undefined) setUserId(userId);
    // if (userInfo !== undefined) setUserInfo(userInfo);
};

export const clearUserAuthInfo = () => {
    localStorage.removeItem('accessToken');
    localStorage.removeItem('refreshToken');
    // localStorage.removeItem('userId');
    // localStorage.removeItem('userInfo');
};